package com.example.backend.controller;

import com.example.backend.service.IncomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class IncomeController {
    @Autowired
    private IncomeService incomeService;

    /**
     * 统计某一天的菜品销售
     * @param shopId 商家ID
     * @param date 日期
     * @return 菜品销售情况的统计数据
     */
    @GetMapping("/income/daily-dish-sales/{id}")
    public Map<String, Object> getDailyDishSales(
        @PathVariable("id") Integer shopId,
        @RequestParam("date") String date
    ) {
        return incomeService.getDailyDishSales(shopId, date);
    }

    /**
     * 统计某一天的总收入
     * @param shopId 商家ID
     * @param date 日期
     * @return 总收入数据
     */
    @GetMapping("/income/daily-income/{id}")
    public Map<String, Object> getDailyTotalIncome(
        @PathVariable("id") Integer shopId,
        @RequestParam("date") String date
    ) {
        return incomeService.getDailyTotalIncome(shopId, date);
    }

    /**
     * 统计菜品销售
     * @param shopId 商家ID
     * @return 菜品销售情况的统计数据
     */
    @GetMapping("/income/dish-sales/{id}")
    public Map<String, Object> getDishSales(@PathVariable("id")  Integer shopId) {
        return incomeService.getDishSales(shopId);
    }

    /**
     * 统计商家总收入
     * @param shopId 商家ID
     * @return 总收入数据
     */
    @GetMapping("/income/total-income/{id}")
    public Map<String, Object> getTotalIncome(@PathVariable("id")  Integer shopId) {
        return incomeService.getTotalIncome(shopId);
    }
}